#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>

int main()
{
	pid_t pid, pid1;
    printf("hello world");
	
	pid = fork();
    printf("change 1");

	if (pid < 0){
        fprintf(stderr, "Fork Failed\n");   // change 1
		return 1;
	}
	else if (pid == 0){
		pid1 = getpid();
		printf("child: pid1 = %d\n", pid);
		printf("child: pid1_1 = %d\n", pid1);
	}
	else {
		pid1 = getpid();
		printf("parent: pid1 = %d\n", pid);
		printf("parent: pid1_1 = %d\n", pid1);
		wait(NULL);
	}
    printf("change 2");
	pid = fork();
	
	if (pid < 0){
		fprintf(stderr, "Fork Failed\n");
		return 1;
	}
	else if (pid == 0){
		pid1 = getpid();
		printf("child: pid2 = %d\n", pid);
		printf("child: pid2_1 = %d\n", pid1);
	}
	else {
		pid1 = getpid();
		printf("parent: pid2 = %d\n", pid);
		printf("parent: pid2_1 = %d\n", pid1);
		wait(NULL);
	}
	
	pid = fork();
	
	if (pid < 0){
		fprintf(stderr, "Fork Failed\n");
		return 1;
	}
	else if (pid == 0){
		pid1 = getpid();
		printf("child: pid3 = %d\n", pid);
		printf("child: pid3_1 = %d\n", pid1);
	}
	else {
		pid1 = getpid();
		printf("parent: pid3 = %d\n", pid);
		printf("parent: pid3_1 = %d\n", pid1);
		wait(NULL);
	}
	return 0;
}
